<%-- 
    Document   : ProjectsByCountry
    Created on : 22/11/2010, 01:33:20 PM
    Author     : Rainiero
--%>

<%@page import="Gui.*"%>
<%@page import="ServiceInterface.IFacade"%>
<%@page import="DataModel.*"%>
<%@page import="Proxy.ProxySAFP"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%

    String header = GuiHelper.GetInstance().GetHeader();
    String footer = GuiHelper.GetInstance().GetFooter();

    IFacade facade = new ProxySAFP().getServiceInterface();

    int pageNumber = RequestHelper.GetPageNumber(request);
    int countryId = RequestHelper.GetCountryId(request);
    ProjectSummary[] projects = new ProjectSummary[0];
    int projectsCount = 0;
    if(countryId != -1)
    {
        projectsCount = facade.GetProjectsCount(Enums.ProjectType.Project, countryId);
        projects = facade.GetProjectsByCountry(countryId, Enums.ProjectType.Project, pageNumber);
    }
    else
    {
        projectsCount = facade.GetProjectsCount(Enums.ProjectType.Project);
        projects = facade.GetProjectsByType(Enums.ProjectType.Project, pageNumber);
    }
    String tableHtml = ProjectGuiHelper.GetInstance().PrintProjectsTable(projects, projectsCount, pageNumber, "ProjectsByCountry.jsp");

    String options = GuiHelper.GetInstance().GetCountryOptions(facade.GetCountries(), countryId);

%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Lista de proyectos por país</title>
        <link rel="stylesheet" type="text/css" href="../Styles/safp.css" />
    </head>
    <body>
        <%= header %>
        <h1>Lista de proyectos por país</h1>
        <form action="../../srvProjectsByCountry" method="post" name="form1" >
            <table>
                <tr>
                    <td class="label">Escoja el país para el cual se presentará el reporte:</td>
                    <td>
                        <select name="ddlCountries">
                            <optgroup label="">
                                <%= options %>
                            </optgroup>
                        </select>
                        <input type="submit" value="Mostrar">
                    </td>
                </tr>
            </table>
        </form>
        <%= tableHtml %>
        <%= footer %>
    </body>
</html>
